package com.ybt.communicate.tcp.client;

import org.apache.log4j.Logger;

import com.ybt.communicate.core.IConnection;
import com.ybt.communicate.core.IProtocol;
import com.ybt.communicate.core.exception.ProtocolException;
import com.ybt.communicate.tcp.configration.TCPRuntimeConfig;

public class TCPClientShort implements IProtocol {
    private static Logger logger = Logger.getLogger(TCPClientShort.class);
    private TCPRuntimeConfig config;
    boolean start;

    public TCPClientShort(TCPRuntimeConfig rconfig) {
        super();
        this.config = rconfig;
    }

    public boolean isStart() {
        // TODO Auto-generated method stub
        return start;
    }

    public void start() throws ProtocolException {
        // TODO Auto-generated method stub
        if (start) {
            // 客户端已经启动
            logger.debug("the client connecting to " + config.getIp()+":"+config.getPort()
                    + " is already started");
            return;
        }

        start = true;
        logger.debug("the client connecting to " + config.getIp()+":"+config.getPort()
                + " has started ...");
    }

    public void stop() throws ProtocolException {
        // TODO Auto-generated method stub
        if (!start) {
            // 客户端已经启动
            logger.debug("the client connecting to " + config.getIp()+":"+config.getPort()
                    + " is already stopped");
            return;
        }
        start = false;
        logger.debug("the client connecting to " + config.getIp()+":"+config.getPort()
                + " has stopped ...");
    }

    public IConnection createConnection() throws ProtocolException {
        // TODO Auto-generated method stub
        return null;
    }

    public IConnection createConnection(long timeout) throws ProtocolException {
        // TODO Auto-generated method stub
        return null;
    }
    
    

}
